package com.dream.learn.myutils;

import java.time.Clock;
import java.time.Instant;
import java.time.LocalDate;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter;

/**
 * @author 凉小枫
 * @detail 时间工具类.
 * @date 2022-01-04 9:38
 */
public class DateUtils {
    public static void main(String[] args) {
        LocalDate localDate = LocalDate.now();//yyyy-MM-dd
        LocalDate startDate = LocalDate.parse("2022-01-02");//yyyy-MM-dd
        LocalDate date1 = LocalDate.parse("2022-01-21", DateTimeFormatter.ofPattern("yyyy-MM-dd"));

        String s = startDate.toString();
        LocalDate of = LocalDate.of(2021, 11, 1);//yyyy-MM-dd 2021-11-01

        int i1 = LocalDate.MAX.compareTo(localDate);

        LocalDate now = LocalDate.now(Clock.systemUTC());
        LocalDate now1 = LocalDate.now(ZoneId.of("-16"));
        int i = localDate.compareTo(startDate);
        int i2 = startDate.compareTo(localDate);
        System.out.println("::::::::" + i
            + "\n" + "::::::::" + i2
            + "\n" + "date1：" + date1
            + "\n" + "of：" + of
            + "\n" + "now：" + now
            + "\n" + "now1：" + now1
            + "\n" + "s：" + s
            + "\n" + "i1：" + i1
        );

        Instant instant1 = Instant.now();
        System.out.println("------------------------------------------" +
            "\n"+"instant1:::" + instant1 +
            "");
    }
}
